package com.opgea.token.domain.entities;

import java.io.Serializable;
import java.util.Arrays;

import javax.persistence.Basic;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Lob;
import com.opgea.token.domain.entities.FileInfo;

/**
 * Entity implementation class for Entity: Document
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Document implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    @Embedded
    private FileInfo fileInfo;
    private String documentType;
    @Lob
    @Basic(fetch = FetchType.LAZY)
    private byte[] document;

    public Document() {
	super();
    }

    public long getId() {
	return id;
    }

    public void setId(long id) {
	this.id = id;
    }

    public FileInfo getFileInfo() {
	return fileInfo;
    }

    public void setFileInfo(FileInfo fileInfo) {
	this.fileInfo = fileInfo;
    }

    public String getDocumentType() {
	return documentType;
    }

    public void setDocumentType(String documentType) {
	this.documentType = documentType;
    }

    public byte[] getDocument() {
	return document;
    }

    public void setDocument(byte[] document) {
	this.document = document;
    }

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + (int) (id ^ (id >>> 32));
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	Document other = (Document) obj;
	if (id != other.id)
	    return false;
	return true;
    }

    @Override
    public String toString() {
	return "Document [id=" + id + ", fileInfo=" + fileInfo
		+ ", documentType=" + documentType + ", document="
		+ Arrays.toString(document) + "]";
    }

}
